/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Sep 12, 2011    @time-created 8:02:19 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.enumhelper;

import util.enumeration.Country;
import util.enumeration.Language;

// this is based on Language enum.. but returns only the supported languages by TCube site
// whereas the language can start off to contain more languages than this.
// use this class instead of the Language
// use LocalizedLanguage if you need to retrieve Language in localized forms (e.g. English = 英文)
public class SupportedLocale {
    
    // alphabetical order
    public static String getSupportedLocaleStringByLanguage(Language language) {
        String locale = null;
        
        switch (language) {
            case CHINESE_CHINA: locale = LanguageCodes.getISOCode(language) + "_" +  CountryCodes.getISOCode(Country.CHINA).toString(); break;
            case ENGLISH_US: locale = LanguageCodes.getISOCode(language) + "_" +  CountryCodes.getISOCode(Country.UNITED_STATES).toString(); break;
            case ENGLISH_SINGAPORE: locale = LanguageCodes.getISOCode(language) + "_" + CountryCodes.getISOCode(Country.SINGAPORE).toString(); break;
            case MALAY: locale = LanguageCodes.getISOCode(language) + "_" +  CountryCodes.getISOCode(Country.MALAYSIA).toString(); break;
        }
        return locale;
    }
    
    public static Language getLanguageBySupportedLocaleString(String locale) {
        Language language = null;
        
        if(locale.equals("en_US")) language = Language.ENGLISH_US;
        else if(locale.equals("en_SG")) language = Language.ENGLISH_SINGAPORE;
        else if(locale.equals("zh_CN")) language = Language.CHINESE_CHINA;
        else if(locale.equals("ms_MY")) language = Language.MALAY;

        return language;
    }
    
    public static Language getSupportedLanguage(Language locale) {
        Language language = null;
        
        switch (locale) {
            case ENGLISH_US: language = Language.ENGLISH_US;
            case ENGLISH_SINGAPORE: language = Language.ENGLISH_SINGAPORE;
            case CHINESE_CHINA: language = Language.CHINESE_CHINA;
            case MALAY: language = Language.MALAY;
        }

        return language;
    }
}
